import requestTypes from '../common';

// 获危险源列表
const getDiscernList = <T = any>(parameter: object = {}) => {
	return requestTypes<T>({
		url: '/SMS/Hazard/QueryPageList',
		method: 'get',
		params: parameter,
	});
};

// 提交危险源识别
const postDiscern = <T = any>(parameter: object = {}) => {
	//注意:post请求使用data属性!data: parameter
	return requestTypes<T>({
		url: '/SMS/Hazard/AddHazard',
		method: 'post',
		data: parameter,
	});
};

// 修改危险源识别
const postChangeDiscern = <T = any>(parameter: object = {}) => {
	//注意:post请求使用data属性!data: parameter
	return requestTypes<T>({
		url: '/SMS/Hazard/UpdateHazard',
		method: 'post',
		data: parameter,
	});
};
const postDeleteDiscern = <T = any>(parameter: object = {}) => {
	//注意:post请求使用data属性!data: parameter
	return requestTypes<T>({
		url: '/SMS/Hazard/DeleteHazard',
		method: 'post',
		data: parameter,
	});
};
//删除危险源详情
const postDeleteDiscernDetail = <T = any>(parameter: object = {}) => {
	//注意:post请求使用data属性!data: parameter
	return requestTypes<T>({
		url: '/SMS/Hazard/DeleteHazardLevel',
		method: 'post',
		data: parameter,
	});
};

//下载模板(需要问一下为什么这个会跨域!!)
const getFile = <T = any>(parameter: object = {}) => {
	//注意:post请求使用data属性!data: parameter
	return requestTypes<T>({
		url: '/Upload/SMS/Batch/Hazard.xlsx',
		method: 'get',
		params: parameter,
	});
};

//上传excel文件
const postExcel = <T = any>(parameter: object = {}) => {
	//注意:post请求使用data属性!data: parameter
	return requestTypes<T>({
		url: '/SMS/Upload/BatchImportData',
		method: 'post',
		data: parameter,
	});
};

export { postExcel, getDiscernList, postDiscern, postChangeDiscern, postDeleteDiscern, postDeleteDiscernDetail, getFile };
